class ApplicationController < ActionController::Base

  include SimpleCaptcha::ControllerHelpers

  protect_from_forgery

    # 后台权限检测
  def checkAdmin
  	is_adminer = false
  	if(session[:user] != nil)
  		is_adminer = true if(session[:user].id == 1)
  	end
  	if(is_adminer == false)
  		redirect_to :action => 'login', :controller =>'user', notice: 'unpassed'
      	return false
  	end
    true
  end

  # 获取指定长度的入库字符串
  def inputString(inputValue, maxlength)
    return nil if(inputValue == nil)
    value = inputValue.lstrip.rstrip # 移除前后空格
    value = value.gsub(/<(.*?)>/, '') # 移除html字符
    value[0,maxlength] # 获取指定长度字符
  end

end

